﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HF.BaseWebCtrlLib;
using HF.Business.Common;//一个业务模块的公共类
using HF.Framework.Web;//框架类
using HF.WorkFlow.Const;
using HF.Framework.DataClientDBAgent;
using HF.Business.Sale;//封装销售业务的类

public partial class SaleInStoreAudit : BaseUserControl
{
    string BillCode = "";
    string BillAudit = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        initData();

    }
    private void initData()
    {
        DataTable dt = SaleInStore.GetSaleInStoreTable(WorkflowInsId);
        if (dt != null && dt.Rows.Count > 0)
        {
            BillCode = dt.Rows[0]["Bill_Code"].ToString();
            BillAudit = dt.Rows[0]["Bill_AuditFlag"].ToString();
            if (BillCode.Length == 0)
            {
                throw new Exception("SaleInStoreAudit Bill_Code 不能为空!");         
            }
            
            if (BillAudit == "0")
            {
                rbtnYes.Checked = true;

            }
            if (BillAudit == "2")
            {
                rbtnNo.Checked = true;

            }

        }
    }
    
    public override void SaveUserControl(bool IsDraft)
    {
        base.SaveUserControl(IsDraft);
        if (rbtnYes.Checked == true)
        {
            if (IsDraft == false && this.CtrlState != WorkFlowConst.STATE_VIEW)//不是草稿
            {
                SaleInStore.SaleInStoreAuditPass(BillCode, UserId, UserName);//审核通过
            }
        }
        else
        {
            if (IsDraft == false && this.CtrlState != WorkFlowConst.STATE_VIEW)//审核不通过
            {
                SaleInStore.SaleInStoreAuditNoPass(BillCode, UserId, UserName);//不同意
            }
        }

    }

    protected void rbtnNo_CheckedChanged(object sender, EventArgs e)
    {

    }
    protected void rbtnYes_CheckedChanged(object sender, EventArgs e)
    {

    }
}
